package com.huluobo.jetpackkotlindemo2006a.paging.db

import androidx.paging.PagingSource
import androidx.room.*

/**
 * Created by lc on 2023/2/25.
 */
@Dao
interface RepoDao {
    //当有新数据加入时,直接替换所有
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(list: List<RepoEntity>)

    @Query("SELECT * FROM RepoEntity")
    fun get(): PagingSource<Int, RepoEntity>

    @Query("DELETE FROM RepoEntity")
    suspend fun clear()

    @Delete
    fun delete(repo: RepoEntity)

    @Update
    fun update(repo: RepoEntity)
}